{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "kernelspec": {
      "display_name": "force",
      "language": "python",
      "name": "force"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.10"
    },
    "colab": {
      "name": "“02-Map-View.ipynb”的副本",
      "provenance": [],
      "toc_visible": true,
      "include_colab_link": true
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/sunyingjian/AI-in-well-logging/blob/master/%E2%80%9C02_Map_View_ipynb%E2%80%9D%E7%9A%84%E5%89%AF%E6%9C%AC.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Vit_9lhboUHJ",
        "colab_type": "text"
      },
      "source": [
        "# Exploring the FORCE 2020 Well Log Challenge - Part 2\n",
        "## Map plots \n",
        "\n",
        "**Brendon Hall, Enthought**\n",
        "\n",
        "bhall@enthought.com\n",
        "\n",
        "Welcome back!  In the [first notebook](https://github.com/brendonhall/FORCE-2020-Lithology/blob/master/notebooks/01-Log-Plot-MPL.ipynb), I showed how to use `matplotlib` to display any well curves for any well in the data supplied for the [2020 FORCE Machine Learning Contest](https://xeek.ai/challenges/force-well-logs/overview). In this notebook, I'm going to use `plotly` to display the well locations on a map. We will create an interactive map that looks like this:\n",
        "\n",
        "![map of wells](https://github.com/brendonhall/FORCE-2020-Lithology/blob/master/notebooks/images/map_view.png?raw=1)\n",
        "\n",
        "This will help build an intuition for how the wells are related spatially.  Perhaps looking at the data in this way will make it easier to apply geologic constraints. Wells that are closer together might have properties that are more correlated with each other, and this could be a useful fact to exploit when building machine learning models to predict log curves and lithofacies. \n",
        "\n",
        "Please get in touch if you have any questions.  You can also join in the conversation on [Software Underground's slack](https://softwareunderground.org/slack) in the **#force_2020_ml_contest** channel.\n",
        "\n",
        "Feel free to use this code, hack it, adapt it for your own needs.\n",
        "\n",
        "The well log data is licensed as [Norwegian License for Open Government Data (NLOD) 2.0](https://data.norge.no/nlod/en/2.0/).\n",
        "The well log labels that are included are provided by FORCE 2020 Machine Learning Contest under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/)."
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Wy6Nhgo2tpsu",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 126
        },
        "outputId": "f73b2a54-d2a8-4301-eef1-7a181bba68b0"
      },
      "source": [
        "!git clone https://github.com/brendonhall/FORCE-2020-Lithology.git"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Cloning into 'FORCE-2020-Lithology'...\n",
            "remote: Enumerating objects: 33, done.\u001b[K\n",
            "remote: Counting objects: 100% (33/33), done.\u001b[K\n",
            "remote: Compressing objects: 100% (25/25), done.\u001b[K\n",
            "remote: Total 33 (delta 9), reused 24 (delta 4), pack-reused 0\u001b[K\n",
            "Unpacking objects: 100% (33/33), done.\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1TZ0hLRetvAP",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "pf75tADIoUHK",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import os.path\n",
        "\n",
        "import numpy as np\n",
        "import pandas as pd\n",
        "\n",
        "import plotly.express as px\n",
        "\n",
        "pd.options.display.max_rows = 8"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Trbox6TeoUHP",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "# change this to the location of the training data on your disk if\n",
        "# you have already downloaded it\n",
        "local_train_csv = '/content/train.csv'\n",
        "train_df = pd.read_csv(local_train_csv, sep=';')\n",
        "    \n",
        "train_well_names = train_df['WELL'].unique()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QeZvDJOZoUHS",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 523
        },
        "outputId": "6e1c04be-2871-4dba-b9b6-3af4e97f7b09"
      },
      "source": [
        "train_df"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>WELL</th>\n",
              "      <th>DEPTH_MD</th>\n",
              "      <th>X_LOC</th>\n",
              "      <th>Y_LOC</th>\n",
              "      <th>Z_LOC</th>\n",
              "      <th>GROUP</th>\n",
              "      <th>FORMATION</th>\n",
              "      <th>CALI</th>\n",
              "      <th>RSHA</th>\n",
              "      <th>RMED</th>\n",
              "      <th>RDEP</th>\n",
              "      <th>RHOB</th>\n",
              "      <th>GR</th>\n",
              "      <th>SGR</th>\n",
              "      <th>NPHI</th>\n",
              "      <th>PEF</th>\n",
              "      <th>DTC</th>\n",
              "      <th>SP</th>\n",
              "      <th>BS</th>\n",
              "      <th>ROP</th>\n",
              "      <th>DTS</th>\n",
              "      <th>DCAL</th>\n",
              "      <th>DRHO</th>\n",
              "      <th>MUDWEIGHT</th>\n",
              "      <th>RMIC</th>\n",
              "      <th>ROPA</th>\n",
              "      <th>RXO</th>\n",
              "      <th>FORCE_2020_LITHOFACIES_LITHOLOGY</th>\n",
              "      <th>FORCE_2020_LITHOFACIES_CONFIDENCE</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>15/9-13</td>\n",
              "      <td>494.5280</td>\n",
              "      <td>437641.96875</td>\n",
              "      <td>6470972.5</td>\n",
              "      <td>-469.501831</td>\n",
              "      <td>NORDLAND GP.</td>\n",
              "      <td>NaN</td>\n",
              "      <td>19.480835</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1.611410</td>\n",
              "      <td>1.798681</td>\n",
              "      <td>1.884186</td>\n",
              "      <td>80.200851</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>20.915468</td>\n",
              "      <td>161.131180</td>\n",
              "      <td>24.612379</td>\n",
              "      <td>NaN</td>\n",
              "      <td>34.636410</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.574928</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65000</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>15/9-13</td>\n",
              "      <td>494.6800</td>\n",
              "      <td>437641.96875</td>\n",
              "      <td>6470972.5</td>\n",
              "      <td>-469.653809</td>\n",
              "      <td>NORDLAND GP.</td>\n",
              "      <td>NaN</td>\n",
              "      <td>19.468800</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1.618070</td>\n",
              "      <td>1.795641</td>\n",
              "      <td>1.889794</td>\n",
              "      <td>79.262886</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>19.383013</td>\n",
              "      <td>160.603470</td>\n",
              "      <td>23.895531</td>\n",
              "      <td>NaN</td>\n",
              "      <td>34.636410</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.570188</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65000</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>15/9-13</td>\n",
              "      <td>494.8320</td>\n",
              "      <td>437641.96875</td>\n",
              "      <td>6470972.5</td>\n",
              "      <td>-469.805786</td>\n",
              "      <td>NORDLAND GP.</td>\n",
              "      <td>NaN</td>\n",
              "      <td>19.468800</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1.626459</td>\n",
              "      <td>1.800733</td>\n",
              "      <td>1.896523</td>\n",
              "      <td>74.821999</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>22.591518</td>\n",
              "      <td>160.173615</td>\n",
              "      <td>23.916357</td>\n",
              "      <td>NaN</td>\n",
              "      <td>34.779556</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.574245</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65000</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>15/9-13</td>\n",
              "      <td>494.9840</td>\n",
              "      <td>437641.96875</td>\n",
              "      <td>6470972.5</td>\n",
              "      <td>-469.957794</td>\n",
              "      <td>NORDLAND GP.</td>\n",
              "      <td>NaN</td>\n",
              "      <td>19.459282</td>\n",
              "      <td>NaN</td>\n",
              "      <td>1.621594</td>\n",
              "      <td>1.801517</td>\n",
              "      <td>1.891913</td>\n",
              "      <td>72.878922</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>32.191910</td>\n",
              "      <td>160.149429</td>\n",
              "      <td>23.793688</td>\n",
              "      <td>NaN</td>\n",
              "      <td>39.965164</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.586315</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65000</td>\n",
              "      <td>1.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1170507</th>\n",
              "      <td>7/1-2 S</td>\n",
              "      <td>3169.4644</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>VESTLAND GP.</td>\n",
              "      <td>Bryne Fm.</td>\n",
              "      <td>8.379244</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>2.537613</td>\n",
              "      <td>75.363937</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>7.019858</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>8.5</td>\n",
              "      <td>28.024338</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.007600</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>26.840818</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65030</td>\n",
              "      <td>2.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1170508</th>\n",
              "      <td>7/1-2 S</td>\n",
              "      <td>3169.6164</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>VESTLAND GP.</td>\n",
              "      <td>Bryne Fm.</td>\n",
              "      <td>8.350248</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>2.491860</td>\n",
              "      <td>66.452843</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>9.049782</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>8.5</td>\n",
              "      <td>28.091282</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.018297</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>27.007942</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65030</td>\n",
              "      <td>2.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1170509</th>\n",
              "      <td>7/1-2 S</td>\n",
              "      <td>3169.7684</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>VESTLAND GP.</td>\n",
              "      <td>Bryne Fm.</td>\n",
              "      <td>8.313779</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>2.447539</td>\n",
              "      <td>55.784817</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>8.903917</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>8.5</td>\n",
              "      <td>28.019775</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.011438</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>27.175179</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65030</td>\n",
              "      <td>2.0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1170510</th>\n",
              "      <td>7/1-2 S</td>\n",
              "      <td>3169.9204</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>VESTLAND GP.</td>\n",
              "      <td>Bryne Fm.</td>\n",
              "      <td>8.294910</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>2.430716</td>\n",
              "      <td>48.432129</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>9.150043</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>8.5</td>\n",
              "      <td>25.985943</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>-0.011398</td>\n",
              "      <td>NaN</td>\n",
              "      <td>NaN</td>\n",
              "      <td>27.342442</td>\n",
              "      <td>NaN</td>\n",
              "      <td>65030</td>\n",
              "      <td>2.0</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>1170511 rows × 29 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "            WELL  ...  FORCE_2020_LITHOFACIES_CONFIDENCE\n",
              "0        15/9-13  ...                                1.0\n",
              "1        15/9-13  ...                                1.0\n",
              "2        15/9-13  ...                                1.0\n",
              "3        15/9-13  ...                                1.0\n",
              "...          ...  ...                                ...\n",
              "1170507  7/1-2 S  ...                                2.0\n",
              "1170508  7/1-2 S  ...                                2.0\n",
              "1170509  7/1-2 S  ...                                2.0\n",
              "1170510  7/1-2 S  ...                                2.0\n",
              "\n",
              "[1170511 rows x 29 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 16
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "HSaqVUsyoUHW",
        "colab_type": "text"
      },
      "source": [
        "我们还将在教程中查看测试井，并根据训练数据查看这些井的位置。 与上面相同，如果您尚未下载测试数据，则该单元将下载该数据。"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "UTu9GX7CoUHW",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "local_test_csv = '/content/test.csv'\n",
        "\n",
        "test_df = pd.read_csv(local_test_csv, sep=';')\n",
        "\n",
        "test_well_names = test_df['WELL'].unique()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "hzax8bsLoUHZ",
        "colab_type": "text"
      },
      "source": [
        "对于本教程，我们只需要两个数据集中的唯一孔名称。 让我们结合两个名称数组，并仅使用此列创建一个数据框。 稍后我们将需要它与井元数据合并。"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "pCrChz2_oUHa",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 357
        },
        "outputId": "d3eee582-ae2c-4746-f08c-6633ab4b5fcc"
      },
      "source": [
        "well_names = np.concatenate((train_well_names, test_well_names))\n",
        "# need this array in a DataFrame for a merge operation below\n",
        "well_names_df = pd.DataFrame({'WELL':well_names})\n",
        "\n",
        "well_names_df"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>WELL</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>15/9-13</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>15/9-15</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>15/9-17</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>16/1-2</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>104</th>\n",
              "      <td>34/3-3 A</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>105</th>\n",
              "      <td>34/6-1 S</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>106</th>\n",
              "      <td>35/6-2 S</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>107</th>\n",
              "      <td>35/9-8</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>108 rows × 1 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "         WELL\n",
              "0     15/9-13\n",
              "1     15/9-15\n",
              "2     15/9-17\n",
              "3      16/1-2\n",
              "..        ...\n",
              "104  34/3-3 A\n",
              "105  34/6-1 S\n",
              "106  35/6-2 S\n",
              "107    35/9-8\n",
              "\n",
              "[108 rows x 1 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 18
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ixG5yeRpoUHd",
        "colab_type": "text"
      },
      "source": [
        "组合数据集中共有108口井(训练井98口，测试井10口)\n",
        "\n",
        "要绘制孔的位置，我们需要知道它们的位置。 训练数据集包含一些UTM坐标（东/北）中的轨迹信息。 我们可以将第一个位置作为井的位置。 但是，并非数据集中的所有孔都具有有效位置。 让我们来看看[NPD Factpages摘要页面]（https://factpages.npd.no/en/wellbore/tableview/exploration/all）中的一些“元”数据。 点击表格第一行上方的“导出CSV”，将数据保存到磁盘。\n",
        "\n",
        "这些数据包含有关油井本身的大量信息，例如操作员，类型，田地，地层以及位置。 给出了两个UTM井口空间坐标以及纬度和经度。 我们将使用经/纬度和一小部分数据与地图图中的井一起显示。 查看NPD网站上的列，并考虑它们的含义。 我们可能会在功能设计中使用一些有用的信息。"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "MZWbGfbPoUHe",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 375
        },
        "outputId": "e926ad67-6a1d-4ea4-8cbf-80a9609c5655"
      },
      "source": [
        "# location of the meta data csv on your machine \n",
        "well_meta_csv = '/content/numpy-private/挪威测井 相关数据.csv'\n",
        "\n",
        "if not os.path.isfile(well_meta_csv):\n",
        "    # load from s3\n",
        "    print('Loading meta data from disk.')\n",
        "    s3_meta_csv = 's3://zarr-depot/wells/FORCE: Machine Predicted Lithology/wellbore_exploration_all.csv'\n",
        "    well_meta_df = pd.read_csv(s3_meta_csv)\n",
        "    well_meta_df.to_csv(well_meta_csv, index=False)\n",
        "    \n",
        "else:\n",
        "    # load from disk\n",
        "    print('Loading meta data from disk.')\n",
        "    well_meta_df = pd.read_csv(well_meta_csv)\n",
        "\n",
        "# rename the columns so they are more readable\n",
        "well_meta_df.rename(columns={'wlbWellboreName': 'WELL',\n",
        "                             'wlbWell': 'WELL_HEAD',\n",
        "                            'wlbNsDecDeg': 'lat',\n",
        "                            'wlbEwDesDeg': 'lon',\n",
        "                            'wlbDrillingOperator': 'Drilling Operator',\n",
        "                            'wlbPurposePlanned': 'Purpose',\n",
        "                            'wlbCompletionYear': 'Completion Year',\n",
        "                            'wlbFormationAtTd': 'Formation'}, inplace=True)\n",
        "\n",
        "# get df of WELL_HEAD and the lat long\n",
        "well_locations_df = well_meta_df[['WELL_HEAD', 'lat', 'lon']].drop_duplicates(subset=['WELL_HEAD'])\n",
        "\n",
        "# we only need a few of the columns for the map plot\n",
        "well_meta_df = well_meta_df[['WELL','Drilling Operator',\n",
        "                            'Purpose','Completion Year', 'Formation']]\n",
        "\n",
        "well_locations_df"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Loading meta data from disk.\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>WELL_HEAD</th>\n",
              "      <th>lat</th>\n",
              "      <th>lon</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>1/2-1</td>\n",
              "      <td>56.887519</td>\n",
              "      <td>2.476583</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>1/2-2</td>\n",
              "      <td>56.992222</td>\n",
              "      <td>2.496572</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>1/3-1</td>\n",
              "      <td>56.855833</td>\n",
              "      <td>2.851389</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>1/3-2</td>\n",
              "      <td>56.936111</td>\n",
              "      <td>2.750000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1949</th>\n",
              "      <td>7325/1-1</td>\n",
              "      <td>73.913528</td>\n",
              "      <td>25.116714</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1950</th>\n",
              "      <td>7325/4-1</td>\n",
              "      <td>73.649319</td>\n",
              "      <td>25.178261</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1951</th>\n",
              "      <td>7335/3-1</td>\n",
              "      <td>73.997183</td>\n",
              "      <td>35.837147</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1952</th>\n",
              "      <td>7435/12-1</td>\n",
              "      <td>74.071725</td>\n",
              "      <td>35.808628</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>1588 rows × 3 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "      WELL_HEAD        lat        lon\n",
              "0         1/2-1  56.887519   2.476583\n",
              "1         1/2-2  56.992222   2.496572\n",
              "2         1/3-1  56.855833   2.851389\n",
              "3         1/3-2  56.936111   2.750000\n",
              "...         ...        ...        ...\n",
              "1949   7325/1-1  73.913528  25.116714\n",
              "1950   7325/4-1  73.649319  25.178261\n",
              "1951   7335/3-1  73.997183  35.837147\n",
              "1952  7435/12-1  74.071725  35.808628\n",
              "\n",
              "[1588 rows x 3 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 19
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1neCKol7oUHh",
        "colab_type": "text"
      },
      "source": [
        "如您所见，元数据文件中有很多孔（将近2000孔）。 我们需要将数据集中的孔与这些孔进行比较，以提取相应的元数据。 使用[NPD井眼和井眼命名准则]中概述的方案命名井眼（https://www.npd.no/globalassets/1-npd/regelverk/tematiske-veiledninger/eng/guidelines-for-designation -of-wells and-wellbores.pdf）。 井使用以下格式标识：\n",
        "\n",
        "[象限编号]/[区块编号]-[井眼ID][侧钻等]\n",
        "\n",
        "例如，在名为的数据集中有两个井\n",
        "\n",
        "`34/5-1 A`, and  `34/5-1 S`\n",
        "\n",
        "这些井具有相同的井口，并代表不同的侧向（相似）。 元文件并不包含我们训练数据中表示的每个旁听的信息。 因此，让我们仅从井名称中提取井头前缀，然后使用它来获取井的位置。"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "O9GPRXmhoUHh",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 357
        },
        "outputId": "541ac433-b347-4895-8871-bb7b8d8f011d"
      },
      "source": [
        "def base_well_name(row):\n",
        "    \n",
        "    well_name = row['WELL']\n",
        "    \n",
        "    return well_name.split()[0]\n",
        "\n",
        "# apply the function to extract the WELL_HEAD base name from the well\n",
        "well_names_df['WELL_HEAD'] = well_names_df.apply(lambda row: base_well_name(row), axis=1)\n",
        "\n",
        "# merge with location data to get lat/lon\n",
        "locations_df = well_names_df.merge(well_locations_df, how='inner', on='WELL_HEAD')\n",
        "# merge with the meta data to get other data\n",
        "locations_df = locations_df.merge(well_meta_df, how='left', on='WELL')\n",
        "locations_df "
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>WELL</th>\n",
              "      <th>WELL_HEAD</th>\n",
              "      <th>lat</th>\n",
              "      <th>lon</th>\n",
              "      <th>Drilling Operator</th>\n",
              "      <th>Purpose</th>\n",
              "      <th>Completion Year</th>\n",
              "      <th>Formation</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>15/9-13</td>\n",
              "      <td>15/9-13</td>\n",
              "      <td>58.373878</td>\n",
              "      <td>1.934128</td>\n",
              "      <td>Den norske stats oljeselskap a.s</td>\n",
              "      <td>APPRAISAL</td>\n",
              "      <td>1982.0</td>\n",
              "      <td>ZECHSTEIN GP</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>15/9-15</td>\n",
              "      <td>15/9-15</td>\n",
              "      <td>58.302069</td>\n",
              "      <td>1.922131</td>\n",
              "      <td>Den norske stats oljeselskap a.s</td>\n",
              "      <td>WILDCAT</td>\n",
              "      <td>1982.0</td>\n",
              "      <td>SKAGERRAK FM</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>15/9-17</td>\n",
              "      <td>15/9-17</td>\n",
              "      <td>58.445608</td>\n",
              "      <td>1.948217</td>\n",
              "      <td>Den norske stats oljeselskap a.s</td>\n",
              "      <td>WILDCAT</td>\n",
              "      <td>1983.0</td>\n",
              "      <td>SMITH BANK FM</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>16/1-2</td>\n",
              "      <td>16/1-2</td>\n",
              "      <td>58.935894</td>\n",
              "      <td>2.222239</td>\n",
              "      <td>Esso Exploration and Production Norway A/S</td>\n",
              "      <td>APPRAISAL</td>\n",
              "      <td>1976.0</td>\n",
              "      <td>BASEMENT</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>...</th>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "      <td>...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>104</th>\n",
              "      <td>34/3-3 A</td>\n",
              "      <td>34/3-3</td>\n",
              "      <td>61.795136</td>\n",
              "      <td>2.717883</td>\n",
              "      <td>BG Norge AS</td>\n",
              "      <td>APPRAISAL</td>\n",
              "      <td>2012.0</td>\n",
              "      <td>BURTON FM</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>105</th>\n",
              "      <td>34/6-1 S</td>\n",
              "      <td>34/6-1</td>\n",
              "      <td>61.582317</td>\n",
              "      <td>2.685472</td>\n",
              "      <td>Norske Conoco A/S</td>\n",
              "      <td>WILDCAT</td>\n",
              "      <td>2002.0</td>\n",
              "      <td>LUNDE FM</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>106</th>\n",
              "      <td>35/6-2 S</td>\n",
              "      <td>35/6-2</td>\n",
              "      <td>61.533606</td>\n",
              "      <td>3.911311</td>\n",
              "      <td>StatoilHydro Petroleum AS</td>\n",
              "      <td>WILDCAT</td>\n",
              "      <td>2009.0</td>\n",
              "      <td>NO FORMAL NAME</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>107</th>\n",
              "      <td>35/9-8</td>\n",
              "      <td>35/9-8</td>\n",
              "      <td>61.285269</td>\n",
              "      <td>3.675594</td>\n",
              "      <td>Wintershall Norge AS</td>\n",
              "      <td>APPRAISAL</td>\n",
              "      <td>2013.0</td>\n",
              "      <td>RANNOCH FM</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>108 rows × 8 columns</p>\n",
              "</div>"
            ],
            "text/plain": [
              "         WELL WELL_HEAD  ...  Completion Year             Formation\n",
              "0     15/9-13   15/9-13  ...           1982.0  ZECHSTEIN GP        \n",
              "1     15/9-15   15/9-15  ...           1982.0  SKAGERRAK FM        \n",
              "2     15/9-17   15/9-17  ...           1983.0  SMITH BANK FM       \n",
              "3      16/1-2    16/1-2  ...           1976.0  BASEMENT            \n",
              "..        ...       ...  ...              ...                   ...\n",
              "104  34/3-3 A    34/3-3  ...           2012.0  BURTON FM           \n",
              "105  34/6-1 S    34/6-1  ...           2002.0  LUNDE FM            \n",
              "106  35/6-2 S    35/6-2  ...           2009.0  NO FORMAL NAME      \n",
              "107    35/9-8    35/9-8  ...           2013.0  RANNOCH FM          \n",
              "\n",
              "[108 rows x 8 columns]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 20
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wuWxxp4ZoUHk",
        "colab_type": "text"
      },
      "source": [
        "我们拥有数据集中所有108口井的数据。\n",
        "\n",
        "现在，让我们向井位数据列表中添加一列，指示这口井是训练井，还是来自测试数据集。"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "bedecRdpoUHl",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "locations_df.loc[locations_df['WELL'].isin(train_well_names), 'Dataset'] = 'Train'\n",
        "locations_df.loc[locations_df['WELL'].isin(test_well_names), 'Dataset'] = 'Test'\n",
        "\n",
        "# save the location and meta data for future use.\n",
        "locations_df.to_csv('force_2020_meta.csv', index=False)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "P3yJhkr2oUHn",
        "colab_type": "text"
      },
      "source": [
        "最后，我们可以使用该位置数据在地图上绘制井位。 我将使用Plotly的[`scatter_mapbox`]（https://plotly.github.io/plotly.py-docs/genic/plotly.express.scatter_mapbox.html）来完成此操作。 那里有很多基于Python的映射选项，但是在下一个笔记本中，我将使用Plotly的Dash框架构建一个交互式仪表板，我们可以在其中放置该图。\n",
        "\n",
        "对于此图，我们将使用Plotly的[mapbox]（https://www.mapbox.com/）界面使用纬度和经度坐标查看井的位置。 这使用的是“开放街道地图”样式，因此我们不需要API密钥。 mapbox提供了许多[很酷的样式]（https://plotly.com/python/mapbox-layers/）来更改绘图的外观。 其中一些要求您[注册]（https://docs.mapbox.com/help/how-mapbox-works/access-tokens/）以获取API密钥。\n",
        "\n",
        "孔用彩色圆点表示。 训练数据集中的孔为​​蓝色，测试集中的孔为​​红色。 将鼠标悬停在孔位置上时，将显示与每个孔相关的元数据。 使用下面的“ scatter_mapbox”函数中的“ hover_data”参数可以很容易地进行配置。"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ZyDa8HODoUHn",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 403
        },
        "outputId": "ee8b9a10-4b09-4357-af1f-5d4ca4afeb92"
      },
      "source": [
        "fig = px.scatter_mapbox(locations_df, lat=\"lat\", lon=\"lon\",\n",
        "                        color='Dataset', \n",
        "                        zoom=5, height=600,\n",
        "                        hover_data={'WELL': True,\n",
        "                                    'lat': False,\n",
        "                                    'lon': False,\n",
        "                                    'Dataset': False,\n",
        "                                    'Drilling Operator': True,\n",
        "                                    'Purpose': True,\n",
        "                                    'Completion Year': True,\n",
        "                                    'Formation': True}\n",
        "                        )\n",
        "fig.update_layout(mapbox_style=\"open-street-map\")\n",
        "fig.update_layout(margin={\"r\":200,\"t\":20,\"l\":200,\"b\":0})\n",
        "fig.show()"
      ],
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "RuntimeError",
          "evalue": "ignored",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mRuntimeError\u001b[0m                              Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-28-27f6cc322088>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      9\u001b[0m                                     \u001b[0;34m'Purpose'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     10\u001b[0m                                     \u001b[0;34m'Completion Year'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m                                     'Formation': True}\n\u001b[0m\u001b[1;32m     12\u001b[0m                         )\n\u001b[1;32m     13\u001b[0m \u001b[0mfig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate_layout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmapbox_style\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"open-street-map\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/plotly/express/_chart_types.py\u001b[0m in \u001b[0;36mscatter_mapbox\u001b[0;34m(data_frame, lat, lon, color, text, hover_name, hover_data, custom_data, size, animation_frame, animation_group, category_orders, labels, color_discrete_sequence, color_discrete_map, color_continuous_scale, range_color, color_continuous_midpoint, opacity, size_max, zoom, center, mapbox_style, title, template, width, height)\u001b[0m\n\u001b[1;32m    995\u001b[0m     \u001b[0msymbol\u001b[0m \u001b[0mmark\u001b[0m \u001b[0mon\u001b[0m \u001b[0ma\u001b[0m \u001b[0mMapbox\u001b[0m \u001b[0mmap\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    996\u001b[0m     \"\"\"\n\u001b[0;32m--> 997\u001b[0;31m     \u001b[0;32mreturn\u001b[0m \u001b[0mmake_figure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlocals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconstructor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mgo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mScattermapbox\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    998\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    999\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/plotly/express/_core.py\u001b[0m in \u001b[0;36mmake_figure\u001b[0;34m(args, constructor, trace_patch, layout_patch)\u001b[0m\n\u001b[1;32m   1170\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1171\u001b[0m     args, trace_specs, grouped_mappings, sizeref, show_colorbar = infer_config(\n\u001b[0;32m-> 1172\u001b[0;31m         \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconstructor\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtrace_patch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1173\u001b[0m     )\n\u001b[1;32m   1174\u001b[0m     \u001b[0mgrouper\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgrouper\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mone_group\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mgrouped_mappings\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mone_group\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/plotly/express/_core.py\u001b[0m in \u001b[0;36minfer_config\u001b[0;34m(args, constructor, trace_patch)\u001b[0m\n\u001b[1;32m   1026\u001b[0m             \u001b[0mall_attrables\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mgroup_attr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1027\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1028\u001b[0;31m     \u001b[0margs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbuild_dataframe\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mall_attrables\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0marray_attrables\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1029\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1030\u001b[0m     \u001b[0mattrs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mk\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mattrables\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mk\u001b[0m \u001b[0;32min\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/plotly/express/_core.py\u001b[0m in \u001b[0;36mbuild_dataframe\u001b[0;34m(args, attrables, array_attrables)\u001b[0m\n\u001b[1;32m    911\u001b[0m         \u001b[0;31m# argument_list and field_list ready, iterate over them\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    912\u001b[0m         \u001b[0;31m# Core of the loop starts here\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 913\u001b[0;31m         \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0margument\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfield\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margument_list\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfield_list\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    914\u001b[0m             \u001b[0mlength\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf_output\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    915\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0margument\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mRuntimeError\u001b[0m: dictionary changed size during iteration"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "73gj0IYXoUHs",
        "colab_type": "text"
      },
      "source": [
        "比赛数据中似乎至少有三个点的群集。 北部有两个集群，向南有一个细长的集群。 每个群集至少有几个测试井。 也许可以使用聚类算法（如kmeans）来分配空间聚类ID，这可能是机器学习的有用功能？ 在不久的将来要测试的东西。\n",
        "\n",
        "In the next notebook we'll build on this map plot, and add some interactivity using Plotly's Dash framework.  I'll show how to build a tool to select and visualize groups of wells not only based on location, but also what curves each well possesses.\n",
        "\n",
        "This notebook is open source content. Text is CC-BY-4.0, code is [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n",
        "\n",
        "### References\n",
        "\n",
        "Bormann P., Aursand P., Dilib F., Dischington P., Manral S. (2020) 2020 FORCE Machine Learning Contest. https://github.com/bolgebrygg/Force-2020-Machine-Learning-competition"
      ]
    }
  ]
}